package com.cloudlead.plugin.scheduler.vo;

import com.cloudlead.plugin.scheduler.action.validator.ScheduleJobParamsValidatorGroup;
import com.cloudlead.plugin.scheduler.vo.dict.ParamType;
import com.cloudlead.common.lang.persistence.AbstractIdEntity;

import javax.validation.constraints.Size;
import com.cloudlead.common.lang.annotation.BelongsTos;
import com.cloudlead.common.lang.annotation.Domain;
import com.cloudlead.common.lang.annotation.Label;

import java.lang.String;
import javax.validation.constraints.NotNull;
import java.lang.Integer;

/**
 * ScheduleJobParams is a Codegen vo type
 */
@BelongsTos(values = { @com.cloudlead.common.lang.annotation.BelongsTo(property = "job", rootField = "jobId") })
@Label("计划任务参数")
@Domain(domainClassName = "com.cloudlead.plugin.scheduler.entity.EScheduleJobParams")
public class ScheduleJobParams extends AbstractIdEntity<String> implements
		Comparable<ScheduleJobParams> {

	private static final long serialVersionUID = 286622400349424L;
	@Label("编号")
	@NotNull(groups = { ScheduleJobParamsValidatorGroup.Update.class })
	@Size(max = 24)
	private String id;

	@Label("所属工作任务")
	@NotNull(groups = { ScheduleJobParamsValidatorGroup.Create.class, ScheduleJobParamsValidatorGroup.Update.class })
	private ScheduleJob job;

	@Label("参数序号")
	@NotNull(groups = { ScheduleJobParamsValidatorGroup.Create.class, ScheduleJobParamsValidatorGroup.Update.class })
	private Integer paramIndex;

	@Label("参数类型")
	@NotNull(groups = { ScheduleJobParamsValidatorGroup.Create.class, ScheduleJobParamsValidatorGroup.Update.class })
	private ParamType paramType;

	@Label("参数")
	@NotNull(groups = { ScheduleJobParamsValidatorGroup.Create.class, ScheduleJobParamsValidatorGroup.Update.class })
	@Size
	private String paramValue;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public ScheduleJob getJob() {
		return job;
	}

	public void setJob(ScheduleJob job) {
		this.job = job;
	}

	public Integer getParamIndex() {
		return paramIndex;
	}

	public void setParamIndex(Integer paramIndex) {
		this.paramIndex = paramIndex;
	}

	public ParamType getParamType() {
		return paramType;
	}

	public void setParamType(ParamType paramType) {
		this.paramType = paramType;
	}

	public String getParamValue() {
		return paramValue;
	}

	public void setParamValue(String paramValue) {
		this.paramValue = paramValue;
	}

	public String toString() {
		return String
				.format("ScheduleJobParams { id : %s,job : %s,paramIndex : %s,paramType : %s,paramValue : %s }",
						id, job, paramIndex, paramType, paramValue);
	}

	@Override
	public int compareTo(ScheduleJobParams o) {
		return paramIndex.compareTo(o.paramIndex);
	}

}
